﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PBOffice.BLL;
using PBOffice.DAL;

public partial class FilesPage_ShowFiles : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        FilesPage_FileIndex.SonPage = "ShowFile";//指明正在使用母版页
    }
    protected void manage_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton btn = sender as ImageButton;
        int rowIndex = ((GridViewRow)btn.NamingContainer).RowIndex;
        string DocId = (GridViewShowFiles.Rows[rowIndex].FindControl("DocId") as Label).Text;
        Response.Redirect("~/FilesPage/FileManage.aspx?id=" + DocId);
    }
    protected void deleted_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton btn = sender as ImageButton;
        int rowIndex = ((GridViewRow)btn.NamingContainer).RowIndex;
        string DocId = (GridViewShowFiles.Rows[rowIndex].FindControl("DocId") as Label).Text;
        FileOperationBLL.DeletToRecycleByDocId(Convert.ToInt32(DocId));
        Response.Redirect("~/FilesPage/ShowFiles.aspx");
    }
    protected void DocName_Click(object sender, EventArgs e)
    {
        LinkButton btn = sender as LinkButton;//实例化一个按钮
        int rowIndex = ((GridViewRow)btn.NamingContainer).RowIndex;//获取触发事件的按钮所在的行
        string Doctype = (GridViewShowFiles.Rows[rowIndex].FindControl("Doctype") as Label).Text;//获取类别编号
        string docId = (GridViewShowFiles.Rows[rowIndex].FindControl("DocId") as Label).Text;//获取文件编号
        List<v_SelectAllDocumentManage> docManage = FileOperationBLL.SelectAllDoc(Convert.ToInt32(docId));
        if (Doctype == "1" && docManage.Count > 0)
        {
            GridViewShowFiles.DataSource = FileOperationBLL.SelectAllDoc(Convert.ToInt32(docId));
            GridViewShowFiles.DataBind();
        }
        else if (!String.IsNullOrEmpty(Doctype))
        {
            Response.Redirect("~/FilesPage/FileManage.aspx?id=" + docId);
        }
    }
}